package com.sg.service.impl;

import com.sg.bean.Commodity;
import com.sg.dao.CommodityDao;
import com.sg.service.CommodityService;
import com.sg.vo.CommodityVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zh
 * 商品业务逻辑实现类
 */
@Service
public class CommodityServiceImpl implements CommodityService {
    @Autowired
    CommodityDao commodityDao;
    @Override
    public List<CommodityVO> findAll() {
        return commodityDao.findAll();
    }

    @Override
    public Commodity findById(int comId) {
        return commodityDao.findById(comId);
    }

    @Override
    public List<CommodityVO> findByName(String comName) {
        return commodityDao.findByName(comName);
    }

    @Override
    public boolean add(Commodity commodity) {
        return commodityDao.add(commodity)>0?true:false;
    }

    @Override
    public boolean update(Commodity commodity) {
        return commodityDao.update(commodity)>0?true:false;
    }

    @Override
    public boolean delete(int[] arrays) {
        return commodityDao.delete(arrays)>0?true:false;
    }

    @Override
    public List<CommodityVO> findByCateId(int cateId) {
        return commodityDao.findByCateId(cateId);
    }

    @Override
    public List<CommodityVO> findByBusinessId(int businessId) {
        return commodityDao.findByBusinessId(businessId);
    }
}
